import request from "@/utils/request";

const COMMON_BASE_URL = "/api";

export const HMI_SETTING_ZONE_API = {
  fetchSettingZoneInfo: (apiPath: string) => {
    return request<any, SettingZoneInfo>({
      url: `${COMMON_BASE_URL}${apiPath}`,
      method: "get",
    });
  },
  setActiveZone: (apiPath: string, zone: number) => {
    return request<any, SettingZoneInfo>({
      url: `${COMMON_BASE_URL}${apiPath}/activate`,
      method: "post",
      data: { active_zone: zone },
    });
  },
  copyZone: (cpu: number, srcZone: number, dstZone: number) => {
    return request<any, ZoneCopyResponse>({
      url: `${COMMON_BASE_URL}/setting/${cpu}/zone/copy`,
      method: "post",
      data: { src_zone: srcZone, dst_zone: dstZone },
    });
  },
};

export interface SettingZoneInfo {
  cpu: number;
  active_zone: number;
  min_zone: number;
  max_zone: number;
}

export interface ZoneCopyResponse {
  cpu: number;
  status?: string;
  error?: string;
  message?: string;
  code?: number;
}
